<template>
  <div class="exhibits-content" :style="{ width: props.info.width + 'rem', height: props.info.height + 'rem' }">
    <div class="list">
      <div v-for="(item, index) in props.info.showpieceList" :key="index" class="exhibits-item">
        <div
          @contextmenu.stop="emit('onContextMenuChild', $event, index)"
          class="item-content"
          :class="{
            'exhibits-item-1': (index + 1) % 6 === 1,
            'exhibits-item-2': (index + 1) % 6 === 2,
            'exhibits-item-3': (index + 1) % 6 === 3,
            'exhibits-item-4': (index + 1) % 6 === 4,
            'exhibits-item-5': (index + 1) % 6 === 5,
            'exhibits-item-6': (index + 1) % 6 === 0,
          }"
        >
          <img class="exhibits-item-bgStyle" :src="setBgStyle((index + 1) % 6)" alt="" />
          <div class="exhibits-item-shadow"></div>
          <div class="cover-box">
            <img
              class="cover"
              v-lazy="getLinkUrl(item.coverUrl, '?imageView2/3/w/600/format/webp')"
              alt=""
              @click="viewImg(item.moduleId, item.id)"
            />
            <div class="flower-btn">
              <div></div>
            </div>
          </div>
          <p class="items-title">
            {{ item.name }}
          </p>
        </div>
        <!-- :style="{
          'background-image':
            (index + 1) % 2 === 0
              ? `url(${publicUrls + 'free/style1/exhibitionStandStyle1ItemRight.png?imageView2/format/webp'})`
              : `url(${publicUrls + 'free/style1/exhibitionStandStyle1ItemLeft.png?imageView2/format/webp'})`,
        }" -->
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { DraggableContainer } from 'vue3-draggable-resizable';
// import FlotMenu from '@/components/flotMenu/OutlineMenu.vue';
import ContextMenu from '@imengyu/vue3-context-menu';
import { getDraggableNumber, getExhibitsHeightRest, getdisabledY } from '@/utils/getRemComputed';
import { ref, reactive, watch, nextTick } from 'vue';
import { exbitMenuShow, exbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';
import { getLinkUrl } from '@/utils/request/upload';

const emit = defineEmits([
  'emitChildItemDraggable',
  'emitChildItemDraggableStyle',
  'emitShowcaseDraggable',
  'emitShowcaseDraggableStyle',
  'onContextMenuChild',
]);
const store = useProjectStore();
const contextMenuTrigger = ref(); //列表盒子dom
const parentLock = ref(true);
const childShow = ref(true);
const draggableResizable = ref(); //父级拖拽盒子ref
const timer = ref();
const ImgVisible = ref(false);
const ImgUrl = ref('');

const props = defineProps({
  width: {
    type: Number || String,
  },
  height: {
    type: Number || String,
  },
  indexs: {
    type: Number,
  },
  info: {
    type: Object,
  },
  childId: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});

const viewImg = (moduleId: number, e?: number) => {
  store.exhibitsModuleId = moduleId;
  store.exhibitsShowpieceid = e;
  store.exhibitsInfoShow = true;
};

const handleMouseDown = (event) => {
  event.stopPropagation();
};
const preventDefaultDrag = (event) => {
  event.stopPropagation();
};
const setBgStyle = (index) => {
  let arr = [
    'https://static.jiyi.show/free/style3/exhibitionStandStyle1bg1.webp',
    'https://static.jiyi.show/free/style3/exhibitionStandStyle1bg2.webp',
    'https://static.jiyi.show/free/style3/exhibitionStandStyle1bg3.webp',
    'https://static.jiyi.show/free/style3/exhibitionStandStyle1bg4.webp',
    'https://static.jiyi.show/free/style3/exhibitionStandStyle1bg5.webp',
    'https://static.jiyi.show/free/style3/exhibitionStandStyle1bg6.webp',
  ];
  return arr[index];
};
// watch(
//   () => props.info.width,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );
// watch(
//   () => props.info.height,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );

//
</script> 

<style lang="less" scoped>
.exhibits-content {
  position: relative;
  display: flex;
  z-index: 999;
  padding: 0 !important;
}
.list {
  display: flex;
  padding: 0 0.2rem;
  width: 100%;
  height: 100%;
}
.active {
  :deep(.flot-menu) {
    display: flex;
  }
}
:deep(.active) {
  z-index: 999;
}
:deep(.vdr-handle) {
  z-index: 66;
}
.flower-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.3);
  border: 3px solid #ffffff;
  border-radius: 50%;
  div {
    width: 12.5px;
    height: 12.5px;
    background: #ffffff;
    border-radius: 50%;
  }
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  transform: translate(-50%, -50%);
  animation: flower 2s linear infinite;
  @keyframes flower {
    0% {
      opacity: 0;
    }
    40% {
      opacity: 100%;
    } 
    80% {
      opacity: 100%;
    }
    100% { 
      opacity: 0;
    }
  }
}
.exhibits-item {  
  width: 320px;
  height: 100%;
} 
.item-content {
  position: relative;
  display: flex; 
  flex-direction: column;
  width: 320px; 
  // background-repeat: no-repeat;
  // background-size: 100% 100%;
  // -webkit-box-reflect: below 0% linear-gradient(transparent, rgba(0, 0, 0, 0.04));
}
.cover-box {
  z-index: 6;
  position: relative;
  width: 200px;
  height: 200px;
  overflow: hidden;
  margin-left: 56px;
}
.cover {
  width: 200px;
  height: 200px;
  object-fit: contain;
  transition: all 0.3s;
}
.cover-box:hover {
  .cover {
    transform: scale(1.2);
  }
}
.items-title {
  width: 180px;
  height: 28px;
  font-family: SourceHanSerifCN-Bold;
  font-size: 18px;
  color: #623333;
  line-height: 28px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: 66px;
  margin-top: 8px;
}
.exhibits-item-shadow {
  position: absolute;
  top: -10px;
  left: 25px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.exhibits-item-1 {
  height: 481px;
  margin-top: 90px;
  // background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1bg1.png);
  .cover-box {
    margin-top: 105px;
  }
  .items-title {
    margin-top: 8px;
  }
  .exhibits-item-shadow {
    z-index: -2;
    background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1shadow1.webp);
    width: 340px;
    height: 470px;
  }
}
.exhibits-item-2 {
  margin-top: 218px;
  height: 433px;
  // background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1bg2.png);
  .cover-box {
    margin-top: 81px;
  }
  .exhibits-item-shadow {
    z-index: -2;
    background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1shadow2.webp);
    width: 340px;
    height: 422px;
  }
}
.exhibits-item-3 {
  height: 571px;
  // background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1bg3.png);
  .cover-box {
    margin-top: 150px;
  }
  .items-title {
  }
  .exhibits-item-shadow {
    z-index: -2;
    background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1shadow3.webp);
    width: 340px;
    height: 560px;
  }
}
.exhibits-item-4 {
  margin-top: 140px;
  height: 511px;
  // background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1bg4.png);
  .cover-box {
    margin-top: 120px;
  }
  .items-title {
  }
  .exhibits-item-shadow {
    z-index: -2;
    background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1shadow4.webp);
    width: 340px;
    height: 500px;
  }
}
.exhibits-item-5 {
  margin-top: 30px;
  height: 541px;
  // background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1bg5.png);
  .cover-box {
    margin-top: 135px;
  }
  .exhibits-item-shadow {
    z-index: -2;
    background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1shadow5.webp);
    width: 340px;
    height: 530px;
  }
}
.exhibits-item-6 {
  height: 461px;
  margin-top: 190px;
  // background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1bg6.png);
  .cover-box {
    margin-top: 95px;
  }
  .items-title {
    margin-top: 8px;
  }
  .exhibits-item-shadow {
    z-index: -2;
    background-image: url(https://static.jiyi.show/free/style3/exhibitionStandStyle1shadow6.webp);
    width: 340px;
    height: 450px;
  }
}
.exhibits-item-bgStyle {  
  position: absolute;   
  top: 0; 
  left: 0;  
  z-index: -1; 
  width: 100%;
  height: 100%;
  // object-fit: contain;
  -webkit-box-reflect: below -12% linear-gradient(transparent, rgba(0, 0, 0, 0.2));
}
</style>
